package de.fh.ffm.elevator;

/**
 * Button for elevator and floor
 * 
 * @author harscher <swe.chr@googlemail.com>
 * 
 */
public abstract class Button {

	/**
	 * is true, when button is pushed
	 */
	private ElevatorManager em;

	/**
	 * is true when light is on
	 */
	private boolean lightOn = false;

	/**
	 * abstract method that is called when you push a button.
	 */
	public abstract void onPush ();

	/**
	 * This method sets an ElevatorManager for the Button.
	 * 
	 * @param em
	 */
	public void setElevatorManager ( ElevatorManager em ) {
		this.em = em;
	}

	/**
	 * @return The elevatormanager for this Button.
	 */
	public ElevatorManager getElevatorManager () {
		return em;
	}

	/**
	 * 
	 * @return True if light is on, false if its off.
	 */
	public boolean isLightOn () {
		return lightOn;
	}

	/**
	 * Sets the lightOn value of this button to true and calls the abstract
	 * method onPush().
	 */
	public void push () {
		if ( lightOn == false ) {
			onPush();
			lightOn = true;
		}
	}

	/**
	 * Sets the lightOn value of this button to false.
	 */
	public void deactivate () {
		lightOn = false;
	}

	/**
	 * Sets the lightOn value of this button to true.
	 */
	public void activate () {
		lightOn = true;
	}

}
